package com.atguigu.gmall.pms.entity.vo;

import com.atguigu.gmall.pms.entity.SpuAttrValueEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.List;
/*
{
      "attrId": "9",
      "attrName": "屏幕尺寸",
      "valueSelected": [
        "7"
      ]
    }
 */
public class SpuAttrValueVO extends SpuAttrValueEntity {
    //private List<String> valueSelected;
    //当jackson将json字符串转为SpuAttrValueVO对象时，只需要将valueSelected的值设置
    // 给valueSelected属性,在set方法中可以编写业务，将valueSelected集合拼接为字符串赋值给attrValue属性
    public void setValueSelected(List<String> valueSelected){
        if(CollectionUtils.isEmpty(valueSelected)){
            return;
        }
        this.setAttrValue(StringUtils.join(valueSelected,","));
    }
}
